package com.leet.code.simple_array;

import java.util.Arrays;

/**
 * @description:    1520.判断能否形成等差数列
 * @author: WYG
 * @time: 2021/1/5 9:37
 */

public class CanMakeArithmeticProgression {
    public boolean canMakeArithmeticProgression(int[] arr) {
        if (arr.length == 2) {
            return true;
        }
        Arrays.sort(arr);
        int sub = arr[1] - arr[0];
        for (int i = 2; i < arr.length; i++) {
            if (arr[i] - arr[i - 1] != sub) {
                return false;
            }
        }
        return true;
    }
}
